#coding: utf-8
class CulturalHeritage::IntegrityState < ActiveRecord::Base
  default_scope where("deleted = 0")
  validates :name, :presence => {:message => "El nombre es requerido"}
  has_many :list_cultural_heritage, :class_name => 'CulturalHeritage::CulturalHeritage',  :foreign_key => 'integrityState'

  def erasable
    ava = CulturalHeritage::CulturalHeritage.count_integrityState_dependencies(id)
    if ava >0
      return "Imposible borrar. Existen dependencias en patrimonio cultural"    
    end
    return nil
  end
end
